package cn.com.blackboard.DataModule4B2.MemoryCache;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import cn.com.blackboard.DataModule4B2.model.DepartmentInfo;

public class DepartmentInfoMemCache {
	private static HashMap<String, DepartmentInfo> cacheMap = new HashMap<String, DepartmentInfo>();
	
	public static boolean isEmpty(){
		return cacheMap.isEmpty();
	}
	
	public static DepartmentInfo getRecordByKey(String key){
		return cacheMap.get(key);
	}
	
	public static List<DepartmentInfo> getListByKeyList(List<String> keyList){
		List<DepartmentInfo> uiList = new ArrayList<DepartmentInfo>();
		for(String key:keyList){
			uiList.add(getRecordByKey(key));
		}
		return uiList;
	}

	public static HashMap<String, DepartmentInfo> getCacheMap() {
		return cacheMap;
	}

	public static void setCacheMap(HashMap<String, DepartmentInfo> cacheMap) {
		DepartmentInfoMemCache.cacheMap = cacheMap;
	}
	
	public static void clear(){
		DepartmentInfoMemCache.cacheMap.clear();
	}
	
	public static void cacheDepartmentInfo(List<DepartmentInfo> departmentInfoList){
		for(DepartmentInfo di:departmentInfoList){
			cacheMap.put(di.getDepartmentId(), di);
		}
	}
}
